<!DOCTYPE html>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- <link rel="icon" href="../../favicon.ico"> -->

    <title>社保登录</title>

    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <!-- <link href="./css/login.css" rel="stylesheet"> -->
    <script src="/js/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
</head>

<body>

<div class="container">
    <div class="alarm" style="display:none">
        <div class="alert alert-danger alert-dismissible " role="alert">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
            <span class="alert-msg"></span>
        </div>
    </div>
    <h2 class="form-signin-heading text-center"><label class="sb-name"></label>社保</h2>
    <div class="alert alert-info alert-dismissible text-center help" role="alert">
        <button type="button" class="close" data-dismiss="alert">
            <span aria-hidden="true"></span><span class="sr-only">Close</span></button>
        <a href="#">如何获取账号</a>
    </div>
    <form class="form-signin sb_form" method="post" id="sb_form" onsubmit="false" name="sb_form">
        <input id="method" type="hidden" name="method" value="login">
        <#--<input id="userId" type="hidden" name="userId" value="121212">-->
        <#--<input id="userSource" type="hidden" name="userSource" value="data">-->

        <div class="form-content">
        </div>
        <div class="form-img">
            <#--<input id="cityCode" type="text" name="cityCode" value="" class="form-control" >-->
        </div>

        <button class="btn btn-lg btn-primary btn-block sb_submit" type="button">登录</button>
    </form>


</div>
</body>
<script type="text/javascript">
    var isImg = true;
</script>
<script>
    // $("#wocao").alert();


    var daImg = "";
    $.get("/sb/getSBPageInfo?key=${actionContext.sb!}", function (data) {
        var daStr = "";
        $(".sb-name").html(data.data.sbName);//社保名称

        var result = data.data.data;
        for (var ipt in result) {
            if (result.hasOwnProperty(ipt)) {
                var input = result[ipt];
                if ("img" == input.type) {
//                    console.log();
                    var ss = ("true" ==input.hidden)? "hide":"";
//                    console.log(ss);
                    daStr += "<div class=\"form-group img_div "+ss+"\"><label for=\"" + input.input_id + "\" class=\"sr-only\">" + input.input_text + "</label>\n<input type=\"text\" id=\"" + input.input_id + "\" class=\"form-control \" style=\"width:30%;display:inline\" name=\"" + input.input_id + "\" placeholder=\"" + input.input_text + "\"> <img data-src=\"\" class=\"img-rounded quc-captcha-img quc-captcha-change\" alt=\"点击刷新\" src=\"\" style=\"width: 80px; height: 30px;\"></div> "
                } else {
                    daStr += "<div class=\"form-group\"><label for=\"" + input.input_id + "\" class=\"sr-only\">" + input.input_text + "</label><input type=\"" + input.type + "\" id=\"" + input.input_id + "\" name=\"" + input.input_id + "\" class=\"form-control\" placeholder=\"" + input.input_text + "\" required></div>";
                }
            }
            console.log(input);
        }
        $(".form-content").append(daStr);
        $(".help").show();
        $("input:eq(1)").focus();
    });


    $(function () {
        $(".form-content").on("click",".quc-captcha-img", function () {
            $(".quc-captcha-img").attr("src", "/sb/getCaptcha?method=verifyimg&r=" + Math.random());
        })

        $(".sb_submit").click(function (e) {
            $.ajax({
                type: "POST",
                url: "/sb/crawler",
                data: $("#sb_form").serializeArray(),
                datatype: "application/json",
                beforeSend: function () {
                    $("#msg").html("logining");
                },
                success: function (data) {
                    if (data.success){
                        location.href = "https://datamore.guoshujinfu.com/sparta/html/socialinsurance/callback?sessionId=${user.sessionId!}&token=${user.token!}&type=${actionContext.sb!}&status=SUCCESS";
                    }else if("-1" == data.errorCode){
//                        var input = data.data;
//                        daImg = "<div class=\"form-group\"><label for=\"" + input.input_id + "\" class=\"sr-only\">" + input.input_text + "</label>\n<input type=\"text\" id=\"" + input.input_id + "\" class=\"form-control \" style=\"width:30%;display:inline\" name=\"" + input.input_id + "\" placeholder=\"" + input.input_text + "\"> <img data-src=\"\" class=\"img-rounded quc-captcha-img quc-captcha-change\" alt=\"点击刷新\" src=\"\" style=\"width: 80px; height: 30px;\"></div> "
                        $(".img_div").removeClass("hide");
                        $(".quc-captcha-img").attr("src", "/sb/getCaptcha?method=verifyimg&r=" + Math.random());
                    }
                    $(".alarm").show();
                    $(".alert-msg").html(data.errorMsg)
                },
                complete: function (XMLHttpRequest, textStatus) {
//                    alert(XMLHttpRequest.responseText);
//                    alert(textStatus);
                },
                error: function () {
                }
            });
        })
//        $(".form-img").on("click", ".sb-city", function () {
//            var tmp = $(this).attr("tmp");
//            location.href = "/sb/index?sb=" + tmp;
//        });
    })
    function toJson() {

    }
</script>

</html>

